home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / XAMPP 1.4.14 / xampp-win32-1.4.14-installer.exe / xampp / php / pear / XML / Transformer.php < prev    next >
PHP Script  |  2004-03-24  |  21KB  |  779 lines

  1. <?php
  2. //
  3. // +---------------------------------------------------------------------------+
  4. // | PEAR :: XML :: Transformer                                                |
  5. // +---------------------------------------------------------------------------+
  6. // | Copyright (c) 2002-2004 Sebastian Bergmann <sb@sebastian-bergmann.de> and |
  7. // |                         Kristian K÷hntopp <kris@koehntopp.de>.            |
  8. // +---------------------------------------------------------------------------+
  9. // | This source file is subject to version 3.00 of the PHP License,           |
  10. // | that is available at http://www.php.net/license/3_0.txt.                  |
  11. // | If you did not receive a copy of the PHP license and are unable to        |
  12. // | obtain it through the world-wide-web, please send a note to               |
  13. // | license@php.net so we can mail you a copy immediately.                    |
  14. // +---------------------------------------------------------------------------+
  15. //
  16. // $Id: Transformer.php,v 1.122.2.3 2004/03/16 06:55:30 sebastian Exp $
  17. //
  18.  
  19. require_once 'XML/Transformer/CallbackRegistry.php';
  20. require_once 'XML/Util.php';
  21.  
  22. /**
  23. * XML Transformations in PHP.
  24. *
  25. * With this class one can easily bind PHP functionality to XML tags,
  26. * thus transforming an XML input tree into another XML tree without
  27. * the need for XSLT.
  28. *
  29. * @author  Sebastian Bergmann <sb@sebastian-bergmann.de>
  30. * @author  Kristian K÷hntopp <kris@koehntopp.de>
  31. * @version $Revision: 1.122.2.3 $
  32. * @access  public
  33. */
  34. class XML_Transformer {
  35.     // {{{ Members
  36.  
  37.     /**
  38.     * @var    object
  39.     * @access private
  40.     */
  41.     var $_callbackRegistry = null;
  42.  
  43.     /**
  44.     * If true, XML attribute and element names will be
  45.     * case-folded.
  46.     * 
  47.     * @var    boolean
  48.     * @access private
  49.     * @see    $_caseFoldingTo
  50.     */
  51.     var $_caseFolding = false;
  52.  
  53.     /**
  54.     * Can be set to either CASE_UPPER or CASE_LOWER
  55.     * and sets the target case for the case-folding.
  56.     *
  57.     * @var    integer
  58.     * @access private
  59.     * @see    $_caseFolding
  60.     */
  61.     var $_caseFoldingTo = CASE_UPPER;
  62.  
  63.     /**
  64.     * When set to TRUE empty XML tags (<foo></foo>) are
  65.     * collapsed to their short-tag (<foo/>) equivalent.
  66.     *
  67.     * @var    boolean
  68.     * @access private
  69.     */
  70.     var $_collapseEmptyTags = false;
  71.  
  72.     /**
  73.     * If true, debugging information will be sent to
  74.     * the error.log.
  75.     *
  76.     * @var    boolean
  77.     * @access private
  78.     * @see    $_debugFilter
  79.     */
  80.     var $_debug = false;
  81.  
  82.     /**
  83.     * If not empty, debugging information will only be generated
  84.     * for XML elements whose names are in this array.
  85.     *
  86.     * @var    array
  87.     * @access private
  88.     * @see    $_debug
  89.     */
  90.     var $_debugFilter = array();
  91.  
  92.     /**
  93.     * Specifies the target to which error messages and
  94.     * debugging messages are sent.
  95.     *
  96.     * @var    string
  97.     * @access private
  98.     * @see    $_debug
  99.     */
  100.     var $_logTarget = 'error_log';
  101.  
  102.     /**
  103.     * @var    array
  104.     * @access private
  105.     */
  106.     var $_attributesStack = array();
  107.  
  108.     /**
  109.     * @var    array
  110.     * @access private
  111.     */
  112.     var $_cdataStack = array('');
  113.  
  114.     /**
  115.     * @var    array
  116.     * @access private
  117.     */
  118.     var $_elementStack = array();
  119.  
  120.     /**
  121.     * @var    integer
  122.     * @access private
  123.     */
  124.     var $_level = 0;
  125.  
  126.     /**
  127.     * @var    string
  128.     * @access private
  129.     */
  130.     var $_lastProcessed = '';
  131.  
  132.     /**
  133.     * @var    boolean
  134.     * @access public
  135.     */
  136.     var $_secondPassRequired = false;
  137.  
  138.     /**
  139.     * @var    integer
  140.     * @access private
  141.     */
  142.     var $_depth = 0;
  143.  
  144.     // }}}
  145.     // {{{ function XML_Transformer($parameters = array())
  146.  
  147.     /**
  148.     * Constructor.
  149.     *
  150.     * @param  array
  151.     * @access public
  152.     */
  153.     function XML_Transformer($parameters = array()) {
  154.         // Parse parameters array.
  155.  
  156.         if (isset($parameters['debug'])) {
  157.             $this->setDebug($parameters['debug']);
  158.         }
  159.  
  160.         $this->_caseFolding       = isset($parameters['caseFolding'])          ? $parameters['caseFolding']          : false;
  161.         $this->_collapseEmptyTags = isset($parameters['collapseEmptyTags'])    ? $parameters['collapseEmptyTags']    : false;
  162.         $this->_caseFoldingTo     = isset($parameters['caseFoldingTo'])        ? $parameters['caseFoldingTo']        : CASE_UPPER;
  163.         $this->_lastProcessed     = isset($parameters['lastProcessed'])        ? $parameters['lastProcessed']        : '';
  164.         $this->_logTarget         = isset($parameters['logTarget'])            ? $parameters['logTarget']            : 'error_log';
  165.  
  166.         $autoload                 = isset($parameters['autoload'])             ? $parameters['autoload']             : false;
  167.         $overloadedNamespaces     = isset($parameters['overloadedNamespaces']) ? $parameters['overloadedNamespaces'] : array();
  168.         $recursiveOperation       = isset($parameters['recursiveOperation'])   ? $parameters['recursiveOperation']   : true;
  169.  
  170.         // Initialize callback registry.
  171.  
  172.         $this->_callbackRegistry = &XML_Transformer_CallbackRegistry::getInstance(
  173.           $recursiveOperation
  174.         );
  175.  
  176.         foreach ($overloadedNamespaces as $namespacePrefix => $object) {
  177.             $this->overloadNamespace(
  178.               $namespacePrefix,
  179.               $object
  180.             );
  181.         }
  182.  
  183.         if ($autoload !== false) {
  184.             $this->_autoload($autoload);
  185.         }
  186.     }
  187.  
  188.     // }}}
  189.     // {{{ function canonicalize($target)
  190.  
  191.     /**
  192.     * Canonicalizes a given attributes array or element name.
  193.     *
  194.     * @param  mixed
  195.     * @return mixed
  196.     * @access public
  197.     */
  198.     function canonicalize($target) {
  199.         if ($this->_caseFolding) {
  200.             if (is_string($target)) {
  201.                 return ($this->_caseFoldingTo == CASE_UPPER) ? strtoupper($target) : strtolower($target);
  202.             } else {
  203.                 return array_change_key_case(
  204.                   $target,
  205.                   $this->_caseFoldingTo
  206.                 );
  207.             }
  208.         }
  209.  
  210.         return $target;
  211.     }
  212.  
  213.     // }}}
  214.     // {{{ function overloadNamespace($namespacePrefix, &$object, $recursiveOperation = '')
  215.  
  216.     /**
  217.     * Overloads an XML Namespace.
  218.     *
  219.     * @param  string
  220.     * @param  object
  221.     * @param  boolean
  222.     * @access public
  223.     */
  224.     function overloadNamespace($namespacePrefix, &$object, $recursiveOperation = '') {
  225.         if (empty($namespacePrefix) ||
  226.             $namespacePrefix == '&MAIN') {
  227.             $namespacePrefix = '&MAIN';
  228.         } else {
  229.             $namespacePrefix = $this->canonicalize($namespacePrefix);
  230.         }
  231.  
  232.         $result = $this->_callbackRegistry->overloadNamespace(
  233.           $namespacePrefix,
  234.           $object,
  235.           $recursiveOperation
  236.         );
  237.  
  238.         if ($result === true) {
  239.             if ($object->secondPassRequired) {
  240.                 $this->_secondPassRequired = true;
  241.             }
  242.  
  243.             // Call initObserver() on the object, if it exists.
  244.  
  245.             if (method_exists($object, 'initObserver')) {
  246.                 $object->initObserver(
  247.                   $namespacePrefix,
  248.                   $this
  249.                 );
  250.             }
  251.         } else {
  252.             $this->sendMessage(
  253.               $result,
  254.               $this->_logTarget
  255.             );
  256.         }
  257.     }
  258.  
  259.     // }}}
  260.     // {{{ function unOverloadNamespace($namespacePrefix)
  261.  
  262.     /**
  263.     * Reverts overloading of a given XML Namespace.
  264.     *
  265.     * @param  string
  266.     * @access public
  267.     */
  268.     function unOverloadNamespace($namespacePrefix) {
  269.         $this->_callbackRegistry->unOverloadNamespace($namespacePrefix);
  270.     }
  271.  
  272.     // }}}
  273.     // {{{ function isOverloadedNamespace($namespacePrefix)
  274.  
  275.     /**
  276.     * Returns true if a given namespace is overloaded,
  277.     * false otherwise.
  278.     *
  279.     * @param  string
  280.     * @return boolean
  281.     * @access public
  282.     */
  283.     function isOverloadedNamespace($namespacePrefix) {
  284.         return $this->_callbackRegistry->isOverloadedNamespace(
  285.           $this->canonicalize($namespacePrefix)
  286.         );
  287.     }
  288.  
  289.     // }}}
  290.     // {{{ function sendMessage($message, $target = 'error_log')
  291.  
  292.     /**
  293.     * Sends a message to a given target.
  294.     *
  295.     * @param  string
  296.     * @param  string
  297.     * @access public
  298.     */
  299.     function sendMessage($message, $target = 'error_log') {
  300.         switch ($target) {
  301.             case 'echo':
  302.             case 'print': {
  303.                 print $message;
  304.             }
  305.             break;
  306.  
  307.             default: {
  308.                 error_log($message);
  309.             }
  310.         }
  311.     }
  312.  
  313.     // }}}
  314.     // {{{ function setCaseFolding($caseFolding)
  315.  
  316.     /**
  317.     * Sets the XML parser's case-folding option.
  318.     *
  319.     * @param  boolean
  320.     * @param  integer
  321.     * @access public
  322.     */
  323.     function setCaseFolding($caseFolding, $caseFoldingTo = CASE_UPPER) {
  324.         if (is_bool($caseFolding) &&
  325.             ($caseFoldingTo == CASE_LOWER || $caseFoldingTo == CASE_UPPER)) {
  326.             $this->_caseFolding   = $caseFolding;
  327.             $this->_caseFoldingTo = $caseFoldingTo;
  328.         }
  329.     }
  330.  
  331.     // }}}
  332.     // {{{ function setCollapsingOfEmptyTags($collapseEmptyTags)
  333.  
  334.     /**
  335.     * Sets the XML parser's case-folding option.
  336.     *
  337.     * @param  boolean
  338.     * @access public
  339.     */
  340.     function setCollapsingOfEmptyTags($collapseEmptyTags) {
  341.         if (is_bool($collapseEmptyTags)) {
  342.             $this->_collapseEmptyTags = $collapseEmptyTags;
  343.         }
  344.     }
  345.  
  346.     // }}}
  347.     // {{{ function setDebug($debug)
  348.  
  349.     /**
  350.     * Enables or disables debugging information.
  351.     *
  352.     * @param  mixed
  353.     * @access public
  354.     */
  355.     function setDebug($debug) {
  356.         if (is_array($debug)) {
  357.             $this->_debug       = true;
  358.             $this->_debugFilter = array_flip($debug);
  359.         }
  360.  
  361.         else if (is_bool($debug)) {
  362.             $this->_debug = $debug;
  363.         }
  364.     }
  365.  
  366.     // }}}
  367.     // {{{ function setLogTarget($logTarget)
  368.  
  369.     /**
  370.     * Sets the target to which error messages and
  371.     * debugging messages are sent.
  372.     *
  373.     * @param  string
  374.     * @access public
  375.     */
  376.     function setLogTarget($logTarget) {
  377.         $this->_logTarget = $logTarget;
  378.     }
  379.  
  380.     // }}}
  381.     // {{{ function setRecursiveOperation($recursiveOperation)
  382.  
  383.     /**
  384.     * Enables or disables the recursive operation.
  385.     *
  386.     * @param  boolean
  387.     * @access public
  388.     */
  389.     function setRecursiveOperation($recursiveOperation) {
  390.         $this->_callbackRegistry->setRecursiveOperation($recursiveOperation);
  391.     }
  392.  
  393.     // }}}
  394.     // {{{ function stackdump()
  395.  
  396.     /**
  397.     * Returns a stack dump as a debugging aid.
  398.     *
  399.     * @return string
  400.     * @access public
  401.     */
  402.     function stackdump() {
  403.         $stackdump = sprintf(
  404.           "Stackdump (level: %s) follows:\n",
  405.           $this->_level
  406.         );
  407.  
  408.         for ($i = $this->_level; $i >= 0; $i--) {
  409.           $stackdump .= sprintf(
  410.             "level=%d\nelement=%s:%s\ncdata=%s\n\n",
  411.             $i,
  412.             isset($this->_elementStack[$i])    ? $this->_elementStack[$i]                                  : '',
  413.             isset($this->_attributesStack[$i]) ? XML_Util::attributesToString($this->_attributesStack[$i]) : '',
  414.             isset($this->_cdataStack[$i])      ? $this->_cdataStack[$i]                                    : ''
  415.           );
  416.         }
  417.  
  418.         return $stackdump;
  419.     }
  420.  
  421.     // }}}
  422.     // {{{ function transform($xml)
  423.  
  424.     /**
  425.     * Transforms a given XML string using the registered
  426.     * PHP callbacks for overloaded tags.
  427.     *
  428.     * @param  string
  429.     * @return string
  430.     * @access public
  431.     */
  432.     function transform($xml) {
  433.         // Don't process input when it contains no XML elements.
  434.  
  435.         if (strpos($xml, '<') === false) {
  436.             return $xml;
  437.         }
  438.  
  439.         $xml = str_replace('&', '&', $xml);
  440.  
  441.         // Create XML parser, set parser options.
  442.  
  443.         $parser = xml_parser_create();
  444.  
  445.         xml_set_object($parser, $this);
  446.         xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, $this->_caseFolding);
  447.  
  448.         // Register SAX callbacks.
  449.  
  450.         xml_set_element_handler($parser, '_startElement', '_endElement');
  451.         xml_set_character_data_handler($parser, '_characterData');
  452.         xml_set_default_handler($parser, '_characterData');
  453.  
  454.         // Parse input.
  455.  
  456.         if (!xml_parse($parser, $xml, true)) {
  457.             $line = xml_get_current_line_number($parser);
  458.  
  459.             $errorMessage = sprintf(
  460.               "Transformer: XML Error: %s at line %d:%d\n",
  461.               xml_error_string(xml_get_error_code($parser)),
  462.               $line,
  463.               xml_get_current_column_number($parser)
  464.             );
  465.  
  466.             $exml = preg_split('/\n/', $xml);
  467.  
  468.             $start = ($line - 3 > 0)             ? $line - 3 : 0;
  469.             $end   = ($line + 3 < sizeof($exml)) ? $line + 3 : sizeof($exml);
  470.  
  471.             for ($i = $start; $i < $end; $i++) {
  472.                 $errorMessage .= sprintf(
  473.                   "line %d: %s\n",
  474.                   $i+1,
  475.                   $exml[$i]
  476.                 );
  477.             }
  478.  
  479.             $this->sendMessage(
  480.               $errorMessage . "\n" . $this->stackdump(),
  481.               $this->_logTarget
  482.             );
  483.  
  484.             return '';
  485.         }
  486.  
  487.         $result = $this->_cdataStack[0];
  488.  
  489.         // Clean up.
  490.  
  491.         xml_parser_free($parser);
  492.  
  493.         $this->_attributesStack = array();
  494.         $this->_cdataStack      = array('');
  495.         $this->_elementStack    = array();
  496.         $this->_level           = 0;
  497.         $this->_lastProcessed   = '';
  498.  
  499.         // Perform second transformation pass, if required.
  500.  
  501.         $secondPassRequired = $this->_secondPassRequired;
  502.  
  503.         if ($secondPassRequired) {
  504.             $this->_depth++;
  505.             $this->_secondPassRequired = false;
  506.             $result = $this->transform($result);
  507.             $this->_depth--;
  508.         }
  509.  
  510.         if ($this->_collapseEmptyTags &&
  511.             $this->_depth == 0) {
  512.             $result = preg_replace(
  513.               '/<(\w+)([^>]*)><\/\\1>/s',
  514.               '<\\1\\2 />',
  515.               $result
  516.             );
  517.         }
  518.  
  519.         $this->_secondPassRequired = $secondPassRequired;
  520.  
  521.         // Return result of the transformation.
  522.  
  523.         return $result;
  524.     }
  525.  
  526.     // }}}
  527.     // {{{ function _startElement($parser, $element, $attributes)
  528.  
  529.     /**
  530.     * SAX callback for 'startElement' event.
  531.     *
  532.     * @param  resource
  533.     * @param  string
  534.     * @param  array
  535.     * @access private
  536.     */
  537.     function _startElement($parser, $element, $attributes) {
  538.         $attributes = $this->canonicalize($attributes);
  539.         $element    = $this->canonicalize($element);
  540.         $qElement   = XML_Util::splitQualifiedName($element, '&MAIN');
  541.         $process    = $this->_lastProcessed != $element;
  542.  
  543.         // Push element's name and attributes onto the stack.
  544.  
  545.         $this->_level++;
  546.         $this->_elementStack[$this->_level]    = $element;
  547.         $this->_attributesStack[$this->_level] = $attributes;
  548.  
  549.         if ($this->_checkDebug($element)) {
  550.             $this->sendMessage(
  551.               sprintf(
  552.                 'startElement[%d]: %s %s',
  553.                 $this->_level,
  554.                 $element,
  555.                 XML_Util::attributesToString($attributes)
  556.               )
  557.             );
  558.         }
  559.  
  560.         if ($process &&
  561.             isset($this->_callbackRegistry->overloadedNamespaces[$qElement['namespace']]['active'])) {
  562.             // The event is handled by a callback
  563.             // that is registered for this namespace.
  564.  
  565.             $cdata = $this->_callbackRegistry->overloadedNamespaces[$qElement['namespace']]['object']->startElement(
  566.               $qElement['localPart'],
  567.               $attributes
  568.             );
  569.         } else {
  570.             // No callback was registered for this element's
  571.             // opening tag, copy it.
  572.  
  573.             $cdata = sprintf(
  574.               '<%s%s>',
  575.               $element,
  576.               XML_Util::attributesToString($attributes)
  577.             );
  578.         }
  579.  
  580.         $this->_cdataStack[$this->_level] = $cdata;
  581.     }
  582.  
  583.     // }}}
  584.     // {{{ function _endElement($parser, $element)
  585.  
  586.     /**
  587.     * SAX callback for 'endElement' event.
  588.     *
  589.     * @param  resource
  590.     * @param  string
  591.     * @access private
  592.     */
  593.     function _endElement($parser, $element) {
  594.         $cdata     = $this->_cdataStack[$this->_level];
  595.         $element   = $this->canonicalize($element);
  596.         $qElement  = XML_Util::splitQualifiedName($element, '&MAIN');
  597.         $process   = $this->_lastProcessed != $element;
  598.         $recursion = false;
  599.  
  600.         if ($process &&
  601.             isset($this->_callbackRegistry->overloadedNamespaces[$qElement['namespace']]['active'])) {
  602.             // The event is handled by a callback
  603.             // that is registered for this namespace.
  604.  
  605.             $result = $this->_callbackRegistry->overloadedNamespaces[$qElement['namespace']]['object']->endElement(
  606.               $qElement['localPart'],
  607.               $cdata
  608.             );
  609.  
  610.             if (is_array($result)) {
  611.                 $cdata   = &$result[0];
  612.                 $reparse = $result[1];
  613.             } else {
  614.                 $cdata   = &$result;
  615.                 $reparse = true;
  616.             }
  617.  
  618.             $recursion = $reparse &&
  619.                          isset($this->_elementStack[$this->_level-1]) &&
  620.                          $this->_callbackRegistry->overloadedNamespaces[$qElement['namespace']]['recursiveOperation'];
  621.         } else {
  622.             // No callback was registered for this element's
  623.             // closing tag, copy it.
  624.  
  625.             $cdata .= '</' . $element . '>';
  626.         }
  627.  
  628.         if ($recursion) {
  629.             // Recursively process this transformation's result.
  630.  
  631.             if ($this->_checkDebug('&RECURSE')) {
  632.                 $this->sendMessage(
  633.                   sprintf(
  634.                     'start recursion[%d]: %s',
  635.                     $this->_level,
  636.                     $cdata
  637.                   )
  638.                 );
  639.             }
  640.  
  641.             $transformer = new XML_Transformer(
  642.               array(
  643.                 'caseFolding'   => $this->_caseFolding,
  644.                 'caseFoldingTo' => $this->_caseFoldingTo,
  645.                 'lastProcessed' => $element
  646.               )
  647.             );
  648.  
  649.             $cdata = substr($transformer->transform("<_>$cdata</_>"),3,-4);
  650.  
  651.             if ($this->_checkDebug('&RECURSE')) {
  652.                 $this->sendMessage(
  653.                   sprintf(
  654.                     'end recursion[%d]: %s',
  655.                     $this->_level,
  656.                     $cdata
  657.                   )
  658.                 );
  659.             }
  660.         }
  661.  
  662.         if ($this->_checkDebug($element)) {
  663.             $this->sendMessage(
  664.               sprintf(
  665.                 'endElement[%d]: %s (with cdata=%s)',
  666.                 $this->_level,
  667.                 $element,
  668.                 $this->_cdataStack[$this->_level]
  669.               )
  670.             );
  671.         }
  672.  
  673.         // Move result of this transformation step to
  674.         // the parent's CDATA section.
  675.  
  676.         $this->_cdataStack[--$this->_level] .= $cdata;
  677.     }
  678.  
  679.     // }}}
  680.     // {{{ function _characterData($parser, $cdata)
  681.  
  682.     /**
  683.     * SAX callback for 'characterData' event.
  684.     *
  685.     * @param  resource
  686.     * @param  string
  687.     * @access private
  688.     */
  689.     function _characterData($parser, $cdata) {
  690.       if ($this->_checkDebug('&CDATA')) {
  691.           $this->sendMessage(
  692.             sprintf(
  693.               'cdata [%d]: %s + %s',
  694.               $this->_level,
  695.               $this->_cdataStack[$this->_level],
  696.               $cdata
  697.             )
  698.           );
  699.       }
  700.  
  701.       $this->_cdataStack[$this->_level] .= $cdata;
  702.     }
  703.  
  704.     // }}}
  705.     // {{{ function _autoload($namespaces)
  706.  
  707.     /**
  708.     * Loads either all (true) or a selection of namespace
  709.     * handlers from XML/Transformer/Namespace/.
  710.     *
  711.     * @param  mixed
  712.     * @access private
  713.     */
  714.     function _autoload($namespaces) {
  715.         $path = dirname(__FILE__) . '/Transformer/Namespace/';
  716.  
  717.         if ($namespaces === true) {
  718.             $namespaces = array();
  719.  
  720.             if ($dir = @opendir($path)) {
  721.                 while (($file = @readdir($dir)) !== false) {
  722.                     if (strstr($file, '.php')) {
  723.                         $namespaces[] = $this->canonicalize(
  724.                           strtolower(
  725.                             substr($file, 0, -4)
  726.                           )
  727.                         );
  728.                     }
  729.                 }
  730.             }
  731.         }
  732.  
  733.         else if (is_string($namespaces)) {
  734.             $namespaces = array($namespaces);
  735.         }
  736.  
  737.         foreach ($namespaces as $namespace) {
  738.             if (@include_once($path . $namespace . '.php')) {
  739.                 $className = 'XML_Transformer_Namespace_' . $namespace;
  740.                 $object    = new $className;
  741.  
  742.                 $this->overloadNamespace(
  743.                   !empty($object->defaultNamespacePrefix) ? $object->defaultNamespacePrefix : $namespace,
  744.                   $object
  745.                 );
  746.             }
  747.         }
  748.     }
  749.  
  750.     // }}}
  751.     // {{{ function _checkDebug($currentElement = '')
  752.  
  753.     /**
  754.     * Checks whether a debug message should be printed
  755.     * for the current event.
  756.     *
  757.     * @param  string
  758.     * @return boolean
  759.     * @access private
  760.     */
  761.     function _checkDebug($currentElement = '') {
  762.         if ($this->_debug &&
  763.             (empty($this->_debugFilter) ||
  764.              isset($this->_debugFilter[$currentElement]))) {
  765.             return true;
  766.         } else {
  767.             return false;
  768.         }
  769.     }
  770.  
  771.     // }}}
  772. }
  773.  
  774. /*
  775.  * vim600:  et sw=2 ts=2 fdm=marker
  776.  * vim<600: et sw=2 ts=2
  777.  */
  778. ?>
  779.